package com.sl.au.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.sl.au.entity.Account;
import com.sl.au.entity.EXDEDeptSumTotal;
import com.sl.au.service.EXDEDeptSumTotalService;

/**
 * 回款分析控制器1
 */
//@RestController
//@RequestMapping(value="/ui/payIncomeAnalysis")
//public class PayIncomeAnalysisController extends BaseController{
//    @RequestMapping(method = RequestMethod.GET)
//    public ModelAndView index(){
//        ModelAndView modelAndView=createLayoutView("paymentSearch/payIncomeAnalysis");
//        return modelAndView;
//    }
//}
@RestController
@RequestMapping(value="/ui/payIncomeAnalysis")
public class PayIncomeAnalysisController extends BaseController{

	@Autowired
	EXDEDeptSumTotalService exdeDeptSumTotalService;
	
    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView index(){
        ModelAndView modelAndView=createLayoutView("paymentSearch/payIncomeAnalysis");
        Account a = this.getMyAccount();
		String userId =a.getUser().getId();
		modelAndView.addObject("userId",userId);
		return modelAndView;
    }
    
    @RequestMapping(value = "getMyTrance", method = RequestMethod.GET)
	public Map<String,Object> getMyTrance(HttpServletRequest request) {
		Map<String,Object> map = new HashMap<String,Object>();
		Account a = this.getMyAccount();
		//String userId = a.getUser().getId();
		//String superior = a.getUser().getSaleArea().getSuperior();//部门
		//String superior = "销售处";
		String dateThisMontha = request.getParameter("dateThisMonth");
		String dateLastMontha = request.getParameter("dateLastMonth");
		String dateLastYeara = request.getParameter("dateLastYear");
		List<EXDEDeptSumTotal> dateThisMonth = null;//本月
		dateThisMonth = exdeDeptSumTotalService.getMyPage(dateThisMontha);
		List<EXDEDeptSumTotal> dateLastMonth = null;//上月
		dateLastMonth = exdeDeptSumTotalService.getMyPage(dateLastMontha);
		List<EXDEDeptSumTotal> dateLastYear = null;//上年
		dateLastYear = exdeDeptSumTotalService.getMyPage(dateLastYeara);
		map.put("dateThisMonth", dateThisMonth);
		map.put("dateLastMonth", dateLastMonth);
		map.put("dateLastYear", dateLastYear);
		map.put("draw", request.getParameter("draw"));
//		map.put("recordsFiltered", users.size());
//		map.put("recordsTotal", users.size());
		return map;
	}
}

